package main

import (
	"fmt"
	"imooc.com/ccmouse/learngo/lang/tree"
)

type myTreeNode struct {
	node *tree.Node
}

//后续遍历
func (myNode *myTreeNode) postOrder() {
	if myNode == nil || myNode.node == nil {
		return
	}

	left := myTreeNode{myNode.node.Left}
	right := myTreeNode{myNode.node.Right}

	left.postOrder()
	right.postOrder()
	myNode.node.Print()
}

func main() {

	fmt.Println()
	var root tree.Node

	root = tree.Node{Value: 3}
	root.Left = &tree.Node{}
	root.Right = &tree.Node{Value: 5}
	root.Right.Left = new(tree.Node)
	root.Left.Right = tree.CreateNode(2)

	root.Right.Left.SetValue(4)
	root.Traverse()

	myRoot := myTreeNode{&root}
	myRoot.postOrder()
	fmt.Println()
}
